##TODO  姿态预估
## https://github.com/ultralytics/assets/releases/tag/v8.2.0
#from  ultralytics import  YOLO
#model = YOLO('yolov8m-pose.pt')
#results = model(source="20240806_163900.mp4", show=True, conf=0.01, save=True)



from ultralytics import YOLO
import cv2
import time

model = YOLO('yolov8m-pose.pt')

# Open the video file
video_path = "20240806_163900.mp4"
cap = cv2.VideoCapture(video_path)

if not cap.isOpened():
    print("打开摄视屏失败！")

# Loop through the video frames
while cap.isOpened():
    # Read a frame from the video
    success, frame = cap.read()
    time.sleep(10)
    if success:
        print("视频读帧成功！")
        # Run YOLOv8 inference on the frame
        results = model(frame)

        # Visualize the results on the frame
        annotated_frame = results[0].plot()

        # Display the annotated frame
        cv2.imshow("YOLOv8 Inference", annotated_frame)

        # Break the loop if 'q' is pressed
        if cv2.waitKey(1) & 0xFF == ord("q"):
            break
    else:
        print("视频读帧失败！")
        # Break the loop if the end of the video is reached
        break

# Release the video capture object and close the display window
cap.release()
cv2.destroyAllWindows()


